//
//  tripsTableViewCell.m
//  INAlienLand
//
//  Created by dllo on 15/7/9.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "tripsTableViewCell.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
@implementation tripsTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.labelContent = [[UILabel alloc]init];
        self.labelContent.numberOfLines = 3;
        [self.contentView addSubview:self.labelContent];
        self.labelTime = [[UILabel   alloc]init];
        self.labeltrip = [[UILabel alloc]init];
        self.imageArr = [NSArray array];
        self.touxiang = [[UIImageView alloc]init];
        self.labelName = [[UILabel alloc]init];
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.touxiang.frame = CGRectMake(5, 5, WIDTH/6, HEIGHT/5);
    self.labelName.frame=CGRectMake(WIDTH/6+7, 5, WIDTH/6*2, HEIGHT/10);
    self.labelTime.frame = CGRectMake(WIDTH/6*3+7, 5, WIDTH/6, HEIGHT/10);
    self.labelContent.frame = CGRectMake(5, HEIGHT/5+5, WIDTH, HEIGHT/5*2);
}
-(void)setImageArr:(NSArray *)imageArr
{
    _imageArr = imageArr;
    [self createImageCollect];
}
-(void)createImageCollect
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(WIDTH/3, HEIGHT/5 *2-5);
    flowLayout.minimumLineSpacing = 2;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.imageCollect = [[UICollectionView alloc]initWithFrame:CGRectMake(5, HEIGHT/5*3-10, WIDTH, HEIGHT/5*2-10) collectionViewLayout:flowLayout];
    [self.contentView addSubview:self.imageCollect];
    self.imageCollect.delegate = self;
    self.imageCollect.dataSource =self;
    [self.imageCollect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.imageArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    return cell;
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
